package uk.co.cdal.cobweb.frontend.GUI;

import java.awt.BorderLayout;
import java.text.DateFormat;
import java.util.Date;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class ChatItem extends JPanel {

	private String message;

	private String date;

	private String from;

	public ChatItem(String from, String message, String date) {
		setMessage(message);
		setDate(date);
		setFrom(from);
		init();
	}

	public void init() {
		BorderLayout bl;
		setLayout(bl = new BorderLayout());
		JLabel topLeft = new JLabel(from + " says: " + message);
		JLabel topRight = new JLabel(date);
		add(topLeft, BorderLayout.NORTH);
		add(topRight, BorderLayout.NORTH);
		JTextArea center = new JTextArea(message);
		center.setEnabled(false);
		add(center, BorderLayout.CENTER);
	}

	/**
	 * @return the date
	 */
	public String getDate() {
		return date;
	}

	/**
	 * @param date
	 *            the date to set
	 */
	public void setDate(String date) {
		this.date = date;
	}

	/**
	 * @return the from
	 */
	public String getFrom() {
		return from;
	}

	/**
	 * @param from
	 *            the from to set
	 */
	public void setFrom(String from) {
		this.from = from;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message
	 *            the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

}
